package com.threadExample;

import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by yijy on 2018/3/15.
 */
public class MyReentrantLock {

    private ReentrantLock lock = new ReentrantLock();
    
    public void menthodA(){
        lock.lock();
        try {
            for (int i=0;i<3;i++)
            {
                System.out.println(Thread.currentThread().getName()+":"+i);
                Thread.sleep(1000);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
            lock.unlock();
        }
    }

    public static void main(String[] args) {
    }
}
